'''
This file is part of DopplerShift.

    DopplerShift is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    DopplerShift is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with DopplerShift.  If not, see <http://www.gnu.org/licenses/>.
'''
import logging

class DSLogging:
    _log_levels = {
     "DEBUG": logging.DEBUG,
     "INFO": logging.INFO,
     "WARNING": logging.WARNING,
     "ERROR": logging.ERROR
     }
    def __init__(self, log_level=None):
        logging.basicConfig(
                            level=self._getLogLevel(log_level),
                            format='%(asctime)s %(levelname)-5.5s [%(name)s] %(message)s'
                            )
    def _getLogLevel(self, log_level):
        if log_level not in self._log_levels:
            return logging.DEBUG
        return self._log_levels[log_level]
    def twistedObserver(self):
        from twisted.python import log
        observer = log.PythonLoggingObserver()
        observer.start()